/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utils;

import dao.AccountDAO;
import dto.Account;
import java.sql.*;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author lab
 */
public class DBConnection {

    static Connection conn = null;

    public static void main(String[] args) {        
        AccountDAO adao = new AccountDAO();
        ArrayList<Account> list = adao.getAllAccounts();
    }

    public static Connection getConnection() {
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=FlowerStore", "xuan", "123");
            return conn;
        } catch (Exception ex) {
            return null;
        }
    }

    public static void disconnect() {
        try {
            conn.close();
        } catch (SQLException ex) {
            Logger.getLogger(DBConnection.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
